import Vue from 'vue';
import App from './App';
import apiUrl from './common/apiUrl';
import myMixin from '@/common/myMixin';
import store from './store';
import cImage from '@/components/c-image';
import serverImage from '@/components/server-image';
import cBotton from '@/components/c-botton.vue'
import cRichText from '@/components/c-rich-text.vue';
import noData from '@/components/no-data.vue';
import textItem from '@/components/text-item.vue';
import uView from 'uview-ui';
// import StatisticSDK from '@/common/StatisticSDK';
import config from '@/common/config.js'

Vue.prototype.$store = store;
Vue.config.productionTip = false;

App.mpType = 'app';
Vue.use(uView);
Vue.component('c-image', cImage);
Vue.component('server-image', serverImage);
Vue.component('c-botton', cBotton)
Vue.component('c-rich-text', cRichText)
Vue.component('no-data', noData)
Vue.component('text-item', textItem)
Vue.config.ignoredElements = [...Vue.config.ignoredElements, 'wx-open-launch-weapp'];
const app = new Vue({
  store,
  ...App,
});
// Vue.use(httpInterceptor, app)
app.$mount();
//mixin
Vue.mixin(myMixin);
//request
Vue.prototype.apiUrl = apiUrl;
// Vue.prototype.statistic = new StatisticSDK();

//request
Vue.prototype.apiUrl = apiUrl;

Vue.prototype.$imagePrefix = config.imagePrefix
Vue.prototype.$platform = uni.getSystemInfoSync().platform
// #ifdef APP-PLUS
Vue.prototype.$pallet = 'APP'
// #endif

// #ifdef MP-WEIXIN
Vue.prototype.$pallet = 'MP-WEIXIN'
// #endif

// #ifdef H5
Vue.prototype.$pallet = 'H5'
// #endif

// uni.addInterceptor('request', {
//   success(args) {
//     const { errMsg, data: outerData } = args;
//     if (errMsg !== 'request:ok') return;
//     // 服务器时间
//     const { now, timestamp } = outerData;
//     const realNow = Number(timestamp || now);
//     realNow && store.commit('setSystemNow', realNow);
//     // 未登录或登录超时
//     const { status, code } = outerData;
//     const isNotLogin = status == 403 || code == 403 || status == 555;
//     if (isNotLogin) {
//       const duration = 2000;
//       uni.showToast({
//         icon: 'none',
//         duration,
//         title: '登录超时',
//         mask: true,
//       });
//       // setTimeout(() => {
//       //   store.commit('logout');
//       //   uni.navigateTo({
//       //     url: '/pages/login/login',
//       //   });
//       // }, duration);
//     }
//   },
// });

// uni.addInterceptor('switchTab', {
//   success() {
//     if (store.state.memberInfo.isAnonymous) {
//       store.commit('logout');
//     }
//   },
// });
